/*
 * @Author: wangdazhuang
 * @Date: 2024-11-29 09:03:14
 * @LastEditTime: 2025-01-25 13:52:11
 * @LastEditors: wangdazhuang
 * @Description: 
 * @FilePath: /pornhub_app/lib/views/douyin/dou_yin_page.dart
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:pornhub_app/components/common_permission_alert.dart';
import 'package:pornhub_app/routes/routes.dart';
import 'package:pornhub_app/services/user_service.dart';
import 'package:pornhub_app/views/douyin/short_video_player/controllers/short_video_player_page_controller.dart';
import 'package:pornhub_app/views/douyin/short_video_player/views/short_video_player_page.dart';

import '../../assets/assets.dart';
import '../../components/app_bar/extend_transparent_app_bar.dart';
import '../../components/tab_bar_indicator/easy_fixed_indicator.dart';
import '../../utils/color.dart';
import '../../utils/extension.dart';
import 'dou_yin_page_controller.dart';

class DouYinPage extends GetView<DouYinPageController> {
  const DouYinPage({super.key});

  AppBar _buildAppBar(BuildContext context) {
    return ExtendTransparentAppBar(
      backColor: null,
      centerTitle: true,
    );
  }

  Widget _buildTabBar() {
    return TabBar(
      controller: controller.tabController,
      isScrollable: false,
      tabs: DouYinPageController.tabs.map((e) => Tab(text: e)).toList(),
      indicator:
          EasyFixedIndicator(width: 23.w, height: 3.w, color: COLOR.white),
      dividerColor: Colors.transparent,
      dividerHeight: 0,
      indicatorPadding: EdgeInsets.only(bottom: 8.w),
      labelStyle: TextStyle(
          color: COLOR.white, fontSize: 18.w, fontWeight: FontWeight.bold),
      unselectedLabelStyle:
          TextStyle(color: COLOR.white.withValues(alpha: 0.7), fontSize: 18.w),
      labelPadding: const EdgeInsets.symmetric(horizontal: 15),
    );
  }

  Widget _buildTabBarView({required double topHeight}) {
    return TabBarView(
      controller: controller.tabController,
      physics: const NeverScrollableScrollPhysics(),
      children: [
        // const ShortVideoPlayerPage(mode: ShortVideoPlayerMode.focus).keepAlive,
        const ShortVideoPlayerPage(mode: ShortVideoPlayerMode.recommend)
            .keepAlive,
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    final appBar = _buildAppBar(context);
    final topHeight =
        ScreenUtil().statusBarHeight + appBar.preferredSize.height;
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: appBar,
      body: _buildTabBarView(topHeight: topHeight),
    );
  }
}
